Application Issues Labs

Goals
  • Demonstrate using strace to determine what a process is doing

  • Demonstrate how to use system monitoring tools and how they react to resource utilization

1. Using strace On Running Processes

  1. On server1.example.com, find the PID of sshd listener, and then use strace to monitor connections to it, where -e accept only shows accept calls.

    # pgrep sshd|head -1
    # strace -ff -e accept -p pid
  2. From desktop1.example.com, use SSH to connect to server1.example.com.

    # ssh server1.example.com
    1. Note what happens.

  3. Press CTRL+c to exit strace.

  4. Exit the SSH session.

2. Monitoring System Utilization with vmstat

  1. On desktop1.example.com, create the script /root/memoryHog.sh.

    #!/bin/bash
    
    delay=1s
    
    echo "begin allocating memory..."
    for index in $(seq 1000); do
        value=$(seq -w -s '' $index $(($index + 100000)))
        eval array$index=$value
    done
    echo "...end allocating memory"
    
    echo "sleeping for $delay"
    sleep $delay
  2. Make the script executable.

  3. In a separate terminal or screen, start vmstat to monitor the system every second.

    # vmstat -SM 1
  4. Flush the disk cache from memory and note the vmstat output change.

    # sync; echo 3 > /proc/sys/vm/drop_caches
  5. Start memoryHog.sh and note the output of vmstat.

    # /root/memoryHog.sh
  6. Press CTRL+c to stop memoryHog and note vmstat changes.

    Don’t let it eat up the entire system memory or you will see the kernel invoke OOM Killer.
  7. Stop vmstat with CTRL+c.

3. Monitoring Processes with top

  1. On desktop1.example.com, in one terminal, start the top command.

  2. In another terminal, start the memoryHog command again and note how top responds.

    # /root/memoryHog.sh
  3. Press CTRL+c to stop memoryHog and note changes in top.

  4. Press CTRL+c to stop top.

4. Monitoring Memory with free

  1. On desktop1.example.com, in one terminal, watch free memory in real time with the free and watch commands.

    # watch free -m
  2. In another terminal, flush the cache and note changes in the free output.

    # sync; echo 3 > /proc/sys/vm/drop_caches
  3. Start the memoryHog command again and note how memory responds.

    # /root/memoryHog.sh
  4. Press CTRL+c to stop memoryHog and note changes in free.

  5. Press CTRL+c to stop free.

5. Monitoring Memory with sar

  1. On desktop1.example.com, in one terminal, watch memory statistics with sar.

    # sar -r 1
  2. In another terminal, flush the cache and note the changes in sar output.

    # sync; echo 3 > /proc/sys/vm/drop_caches
  3. Start the memoryHog command again and note how memory responds.

    # /root/memoryHog.sh
  4. Press CTRL+c to stop memoryHog and note the changes in sar.

  5. Press CTRL+c to stop sar.

6. Monitoring CPU with sar

  1. On desktop1.example.com, in one terminal, watch CPU statistics with sar.

    # sar -u 1
  2. On another terminal, start the memoryHog command again and note how the CPU responds.

    # /root/memoryHog.sh
  3. Press CTRL+c to stop memoryHog and note the changes in sar.

  4. Press CTRL+c to stop sar.